#!/bin/bash

tar cf /tmp/tmp $(find src/ore -type f -name '*.java')

for src in $(find src/ore -type f -name '*.java')
do
 lno=$(egrep -n '^package ore' $src | sed 's/:package.*//; s/.*://')
 lno=$(( $lno - 1 ))
 if cat $src | sed "1,${lno}d" > /tmp/tmp
 then
  touch -r $src /tmp/tmp
  cat HEAD.txt /tmp/tmp > ${src}
  touch -r /tmp/tmp ${src}
  ls -l ${src}
 else
  echo error
  exit 1
 fi
done
